* Replication code for:

*** Anne Rasmussen & Stefanie Reher, 
*** "Perceived Legitimacy of Interest Groups in Policymaking: The Impacts of Cause and Business Group Ties", 
*** European Journal of Political Research

* 6 August 2024

************************************************************************

ssc install coefplot, replace
ssc install estout, replace

* Save the dataset "RR_EJPR_2024.dta" and replace "PATH" below with the path to its folder:
global wd "PATH" 

use $wd\RR_EJPR_2024.dta, clear


********************************************************************************
********************************************************************************

*** SI 2. Descriptive statistics of group ties and correlations between them

*** Figure S2 (SI): mean group trust and engagement; descriptives of trust and engagement by country

* Figure S2, left-hand side: group trust
graph bar trust_business trust_env trust_cons trust_cause, over(country) /// 
	title("Group trust") graphregion(color(white)) name(bar1, replace)
	
* mean and std. dev. of group trust 
bysort country: sum trust_business trust_env trust_cons trust_cause trustdiff
sum trust_business trust_cause trust_env trust_cons trustdiff

* Figure S2, right-hand side: group engagement
graph bar assoc_business assoc_env assoc_cons assoc_cause, over(country) ///
	title("Group engagement") graphregion(color(white)) name(bar2, replace)
	
* mean and std. dev. of group trust 
bysort country: sum assoc_business assoc_env assoc_cons assoc_cause
sum assoc_business assoc_cause assoc_env assoc_cons 

graph combine bar1 bar2, col(2) graphregion(color(white)) xsize(5) ysize(2) name(bar, replace)
graph save bar $wd\FigS2.gph, replace
graph export $wd\FigS2.png, replace

* mean and std. dev. of ideology (attitudina ties)
bysort country: sum ideology 

*** Table S2 (SI): Correlations between group ties measures 

pwcorr trust_business trust_env trust_cons ideology assoc_business ///
	 assoc_env assoc_cons, sig obs, if issue==1 & trust_business!=. & trust_env!=. & trust_cons!=. & ///
	 ideology!=. & assoc_business!=. & assoc_env!=. & assoc_cons!=.
	 
********************************************************************************
********************************************************************************

*** Reliability (Cronbach's alpha) of legitimacy scales (footnote 2)

* Procedural legitimacy:
alpha leg_fair leg_actors leg_democratic

* Substantive legitimacy:
alpha leg_right leg_citizens leg_affected

********************************************************************************
********************************************************************************

*** Table S3 (SI): Factor analysis with legitimacy items

factor leg_fair leg_right leg_actors leg_citizens leg_democratic leg_affected
rotate, oblique oblimin

********************************************************************************
********************************************************************************
********************************************************************************

***** MAIN ANALYSIS 

*** Table S4 (SI): Linear regression of perceived legitimacy on interest group involvement, moderated by ties 

*** Model 1 and Figure 2: Effects of interest group involvement in decision-making on perceived legitimacy

regress leg_proc ib2.repres ib2.attain i.public outfav group issue i.country, cluster(id)
* to compare both cases of unequal representation, change the reference category:
* regress leg_proc ib3.repres ib2.attain i.public outfav group issue i.country, cluster(id)
est store m1

* Figure 2
coefplot, keep(*.repres) base xline(0) xtitle("AMCE of group involvement on perceived legitimacy") graphregion(color(white)) name(g, replace)
graph save g $wd\Fig2.gph, replace
graph export $ws\Fig2.png, replace

********************************************************************************

*** Model 2 and Figure 4: Interaction with relative trust

regress leg_proc ib2.repres##c.trustdiff ib2.attain i.public outfav group issue i.country, cluster(id)
est store m2

* generate subset without observations missing in this model for histogram:
cap gen m2a=.
replace m2a=1 if leg_proc!=. & repres!=. & attain!=. & public!=. & outfav!=. & group!=. & issue!=. & country!=. & trustdiff!=.

* Figure 3
margins, at(trustdiff=(-10(1)10) repres=(1(1)4))
marginsplot, legend(order(5 "Neither" 6 "Both" 7 "More cause" 8 "More business") size(small)) xtitle("Relative trust") ///
	title(" ") ytitle("Predicted legitimacy", height(5)) xlabel(-10(5)10) ylabel(1(1)4) recast(line) ciopts(color(%30) lwidth(none)) ///
	recastci(rarea) xsize(3) ysize(3) graphregion(color(white)) ///
	addplot(hist trustdiff if m2a==1, width(1) yaxis(2) yscale(alt) fcolor(%10) ) ///
	name(g1, replace)
graph save g2 $wd\Fig3.gph, replace
graph export $wd\Fig3.png, replace

* to estimate the difference between the two cases of unequal representation at the maximum levels 
	* of relative trust in either group type: create new trust variable where one extreme (-10 and 10)
	* equals 0, respectively:
gen trust1 = trustdiff + 10 // -10 on trustdiff equals 0 on trust1
gen trust2 = trustdiff - 10 // 10 on trustdiff equals 0 on trust1

regress leg_proc ib3.repres##c.trust1 ib2.attain i.public outfav group issue i.country, cluster(id)
regress leg_proc ib3.repres##c.trust2 ib2.attain i.public outfav group issue i.country, cluster(id)

********************************************************************************

*** Model 3 and Figure 4: Interaction with engagement

regress leg_proc ib2.repres##i.assoc_engage ib2.attain i.public outfav group issue i.country, cluster(id)
est store m3

* Figure 4
margins, at(assoc_engage=(1(1)4)) by(repres)
marginsplot, legend(order(5 "Neither" 6 "Both" 7 "More cause" 8 "More business")) ///
	xtitle("Interest group engagement") ytitle("Predicted legitimacy", height(5)) ///
	title(" ") xlabel(,angle(45)) recast(scatter) recastci(rspike) xsize(3.2) ysize(4) ///
	graphregion(color(white)) name(g, replace)
graph save g3 $wd\Fig4.gph, replace
graph export $wd\Fig4.png, replace

********************************************************************************

*** Model 4 and Figure 5: Interaction with engagement

cap gen m4=.
replace m4=1 if leg_proc!=. & repres!=. & attain!=. & public!=. & outfav!=. & group!=. & issue!=. & country!=. & ideology!=.

regress leg_proc ib2.repres##c.ideology ib2.attain i.public outfav group issue i.country, cluster(id)
est store m4

* Figure 5
margins, at(ideology=(0(1)10) repres=(1(1)4))
marginsplot, legend(order(5 "Neither" 6 "Both" 7 "More cause" 8 "More business") size(small)) xtitle("Left-right ideology") ///
	title(" ") ytitle("Predicted legitimacy", height(5)) xlabel(0(2)10) ylabel(1(1)4) recast(line) ciopts(color(%30) lwidth(none)) ///
	recastci(rarea) xsize(3) ysize(3) graphregion(color(white)) ///
	addplot(hist ideology if m4==1, width(1) yaxis(2) yscale(alt) fcolor(%10) ) ///
	name(g1, replace)
graph save g1 $wd\Fig5.gph, replace
graph export $wd\Fig5.png, replace

********************************************************************************

* Table S4
#delimit;
 esttab m1 m2 m3 m4
		using $wd\TableS4.rtf, replace  
		b(%10.3f) se bic 
		obslast star(* 0.05 ** 0.01 *** 0.001)
		mtitles ("(1)" "(2)" "(3)" "(4)") label
		nogaps compress   nonumbers  
nonotes; 

********************************************************************************
********************************************************************************
********************************************************************************

***** DIAGNOSTICS AND ROBUSTNESS CHECKS

*** SI 5.1 Randomization 

regress age i.repres i.attain i.public i.country, cluster(id)
est store M1
regress female i.repres i.attain i.public i.country, cluster(id)
est store M2

* Table S5
esttab M1 M2 using $wd\TableS5.rtf, replace  ///
		b(%10.3f) se bic obslast star(* 0.05 ** 0.01 *** 0.001) ///
		mtitles ("Age" "Female") label nogaps compress nonumbers nonotes 

********************************************************************************
********************************************************************************

*** SI 5.2 Issue order

* Table S6: Models from Table S4 among experimental group 1 (hybrid cars first) 

regress leg_proc ib2.repres ib2.attain i.public outfav issue i.country if group==1, cluster(id)
est store m1a
regress leg_proc ib2.repres##c.trustdiff ib2.attain i.public outfav issue i.country if group==1, cluster(id)
est store m2a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.trustdiff ib2.attain i.public outfav issue i.country if group==1, cluster(id)
regress leg_proc ib2.repres##i.assoc_engage ib2.attain i.public outfav issue i.country if group==1, cluster(id)
est store m3a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##i.assoc_engage ib2.attain i.public outfav issue i.country if group==1, cluster(id)
regress leg_proc ib2.repres##c.ideology ib2.attain i.public outfav issue i.country if group==1, cluster(id)
est store m4a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.ideology ib2.attain i.public outfav issue i.country if group==1, cluster(id)

#delimit;
 esttab m1a m2a m3a m4a
		using $wd\TableS6.rtf, replace  
		b(%10.3f) se bic 
		obslast star(* 0.05 ** 0.01 *** 0.001)
		mtitles ("(1)" "(2)" "(3)" "(4)") label
		nogaps compress   nonumbers  
nonotes; 

********************************************************************************

* Table S7: Models from Table S4 among experimental group 2 (sugar content first) 

regress leg_proc ib2.repres ib2.attain i.public outfav issue i.country if group==2, cluster(id)
est store m1b
regress leg_proc ib2.repres##c.trustdiff ib2.attain i.public outfav issue i.country if group==2, cluster(id)
est store m2b
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.trustdiff ib2.attain i.public outfav issue i.country if group==2, cluster(id)
regress leg_proc ib2.repres##i.assoc_engage ib2.attain i.public outfav issue i.country if group==2, cluster(id)
est store m3b
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##i.assoc_engage ib2.attain i.public outfav issue i.country if group==2, cluster(id)
regress leg_proc ib2.repres##c.ideology ib2.attain i.public outfav issue i.country if group==2, cluster(id)
est store m4b
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.ideology ib2.attain i.public outfav issue i.country if group==2, cluster(id)

#delimit;
 esttab m1b m2b m3b m4b
		using $wd\TableS7.rtf, replace  
		b(%10.3f) se bic 
		obslast star(* 0.05 ** 0.01 *** 0.001)
		mtitles ("(1)" "(2)" "(3)" "(4)") label
		nogaps compress   nonumbers  
nonotes; 

********************************************************************************
********************************************************************************

*** SI 5.3 Sample split by issue 

* Table S8: Models from Table S4 on sample of hybrid cars experiment
regress leg_proc ib2.repres ib2.attain i.public outfav group i.country if issue==1, cluster(id)
est store m1a
regress leg_proc ib2.repres##c.trustdiff ib2.attain i.public outfav group i.country if issue==1, cluster(id)
est store m2a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.trustdiff ib2.attain i.public outfav group i.country if issue==1, cluster(id)
regress leg_proc ib2.repres##i.assoc_engage ib2.attain i.public outfav group i.country if issue==1, cluster(id)
est store m3a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##i.assoc_engage ib2.attain i.public outfav group i.country if issue==1, cluster(id)
regress leg_proc ib2.repres##c.ideology ib2.attain i.public outfav group i.country if issue==1, cluster(id)
est store m4a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.ideology ib2.attain i.public outfav group i.country if issue==1, cluster(id)

#delimit;
 esttab m1a m2a m3a m4a
		using $wd\TableS8.rtf, replace  
		b(%10.3f) se bic 
		obslast star(* 0.05 ** 0.01 *** 0.001)
		mtitles ("(1)" "(2)" "(3)" "(4)") label
		nogaps compress   nonumbers  
nonotes; 

********************************************************************************

* Table S9: Models from Table S4 on sample of sugar content experiment
regress leg_proc ib2.repres ib2.attain i.public outfav group i.country if issue==2, cluster(id)
est store m1b
regress leg_proc ib2.repres##c.trustdiff ib2.attain i.public outfav group i.country if issue==2, cluster(id)
est store m2b
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.trustdiff ib2.attain i.public outfav group i.country if issue==2, cluster(id)
regress leg_proc ib2.repres##i.assoc_engage ib2.attain i.public outfav group i.country if issue==2, cluster(id)
est store m3b
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##i.assoc_engage ib2.attain i.public outfav group i.country if issue==2, cluster(id)
regress leg_proc ib2.repres##c.ideology ib2.attain i.public outfav group i.country if issue==2, cluster(id)
est store m4b
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.ideology ib2.attain i.public outfav group i.country if issue==2, cluster(id)

#delimit;
 esttab m1b m2b m3b m4b
		using $wd\TableS9.rtf, replace  
		b(%10.3f) se bic 
		obslast star(* 0.05 ** 0.01 *** 0.001)
		mtitles ("(1)" "(2)" "(3)" "(4)") label
		nogaps compress   nonumbers  
nonotes; 

********************************************************************************
********************************************************************************

*** SI 5.4 Sample split by country

* Table S10: Models from Table S4 estimated on UK sample 

regress leg_proc ib2.repres ib2.attain i.public outfav issue group if country==1, cluster(id)
est store m1a
regress leg_proc ib2.repres##c.trustdiff ib2.attain i.public outfav issue group if country==1, cluster(id)
est store m2a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.trustdiff ib2.attain i.public outfav issue group if country==1, cluster(id)
regress leg_proc ib2.repres##i.assoc_engage ib2.attain i.public outfav issue group if country==1, cluster(id)
est store m3a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##i.assoc_engage ib2.attain i.public outfav issue group if country==1, cluster(id)
regress leg_proc ib2.repres##c.ideology ib2.attain i.public outfav issue group if country==1, cluster(id)
est store m4a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.ideology ib2.attain i.public outfav issue group if country==1, cluster(id)

#delimit;
 esttab m1a m2a m3a m4a
		using $wd\TableS10.rtf, replace  
		b(%10.3f) se bic 
		obslast star(* 0.05 ** 0.01 *** 0.001)
		mtitles ("(1)" "(2)" "(3)" "(4)") label
		nogaps compress   nonumbers  
nonotes; 

* Table S11: Models from Table S4 estimated on US sample

regress leg_proc ib2.repres ib2.attain i.public outfav issue group if country==2, cluster(id)
est store m1a
regress leg_proc ib2.repres##c.trustdiff ib2.attain i.public outfav issue group if country==2, cluster(id)
est store m2a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.trustdiff ib2.attain i.public outfav issue group if country==2, cluster(id)
regress leg_proc ib2.repres##i.assoc_engage ib2.attain i.public outfav issue group if country==2, cluster(id)
est store m3a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##i.assoc_engage ib2.attain i.public outfav issue group if country==2, cluster(id)
regress leg_proc ib2.repres##c.ideology ib2.attain i.public outfav issue group if country==2, cluster(id)
est store m4a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.ideology ib2.attain i.public outfav issue group if country==2, cluster(id)

#delimit;
 esttab m1a m2a m3a m4a
		using $wd\TableS11.rtf, replace  
		b(%10.3f) se bic 
		obslast star(* 0.05 ** 0.01 *** 0.001)
		mtitles ("(1)" "(2)" "(3)" "(4)") label
		nogaps compress   nonumbers  
nonotes; 

* Table S12. Models from Table S4 estimated on German sample

regress leg_proc ib2.repres ib2.attain i.public outfav issue group if country==3, cluster(id)
est store m1a
regress leg_proc ib2.repres##c.trustdiff ib2.attain i.public outfav issue group if country==3, cluster(id)
est store m2a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.trustdiff ib2.attain i.public outfav issue group if country==3, cluster(id)
regress leg_proc ib2.repres##i.assoc_engage ib2.attain i.public outfav issue group if country==3, cluster(id)
est store m3a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##i.assoc_engage ib2.attain i.public outfav issue group if country==3, cluster(id)
regress leg_proc ib2.repres##c.ideology ib2.attain i.public outfav issue group if country==3, cluster(id)
est store m4a
	* change reference category of representation: "more cause"
	regress leg_proc ib3.repres##c.ideology ib2.attain i.public outfav issue group if country==3, cluster(id)

#delimit;
 esttab m1a m2a m3a m4a
		using $wd\TableS12.rtf, replace  
		b(%10.3f) se bic 
		obslast star(* 0.05 ** 0.01 *** 0.001)
		mtitles ("(1)" "(2)" "(3)" "(4)") label
		nogaps compress   nonumbers  
nonotes; 

